﻿using Manon.Admin.Web.Application;
using Manon.Admin.Web.Application.Dtos.News;
using Manon.Core;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace Manon.Admin.Web.Controllers
{
    public class NewsCategoryController : Controller
    {
        private readonly INewsService _newsService;
        public NewsCategoryController(INewsService newsService)
        {
            _newsService = newsService;
        }

        public IActionResult Index()
        {
            return View();
        }
        public IActionResult Edit()
        {
            return View();
        }


        [Authorize]
        [HttpGet]
        public async Task<List<NewsCategoryOutput>> GetNewsCategoryList()
        { 
            var result = await _newsService.GetNewsCateogryList();

            return result;
        }

        [Authorize]
        [HttpPost]
        public async Task<Result> SaveNewsCategory([FromBody] NewsCategoryInput Input)
        { 
            var result = await _newsService.SaveNewsCategory(Input);
            return result;
        }
        [Authorize]
        [HttpGet]
        public async Task<NewsCategoryOutput> GetNewsCategory(int CategoryId)
        { 
            var result = await _newsService.GetNewsCategory(CategoryId);
            return result;
        }
        [Authorize]
        [HttpPost]
        public async Task<Result> SetEnabled(int CategoryId, bool Enabled)
        { 
            var result = await _newsService.SetNewsCategoryEnabled(CategoryId, Enabled);
            return result;
        }
    }
}
